﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using DevExpress.XtraEditors;


namespace DXW
{
    public partial class FrmMain : RibbonForm
    {
        #region Properties
        public static bool Trangthai_Dangnhap = false;
        #endregion

        #region Metod
        public FrmMain()
        {
            InitializeComponent();
            InitSkinGallery();
        }

        void frmLogin_Login_Thanhcong(object sender, Sukien e)
        {
            tabDanhmuc.Visible = e.Active_TabDanhmuc;
            btnDangnhap.Caption = "Đăng xuất";
        }

        void InitSkinGallery()
        {
            SkinHelper.InitSkinGallery(rgbiSkins, true);
        }
        #endregion

        #region Hệ thống
        private void FrmMain_Load(object sender, EventArgs e)
        {
            FrmLogin frmLogin = new FrmLogin(this);
            frmLogin.Login_Thanhcong += new delegate_Login(frmLogin_Login_Thanhcong);
            foreach (var x in MdiChildren) if (x is FrmLogin) { x.Activate(); return; }
            frmLogin.MdiParent = this ;
            frmLogin.Show();
        }

        private void btnDangnhap_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Trangthai_Dangnhap)
            {
                //Cho thông báo xác nhận đăng xuất ko anh
                Trangthai_Dangnhap = false;
                tabDanhmuc.Visible = false;
                btnClose_ItemClick(null, null);
                btnDangnhap.Caption = "Đăng nhập";
            }
            else
            {
                FrmMain_Load(null, null);
            }
        }

        private void btnClose_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var frm in MdiChildren) frm.Close();
        }

        private void btnExit_ItemClick(object sender, ItemClickEventArgs e)
        {
            Application.Exit();
        }
        #endregion

        #region Danh mục
        private void btnBophan_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmBophan>(this);
        }

        private void btnVitri_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmVitri>(this);
        }

        private void btnTruong_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmTruong>(this);
        }

        private void btnChuyennganh_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmChuyennganh>(this);
        }

        private void btnBangcap_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmBangcap>(this);
        }

        private void btnTrinhdo_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmTrinhdo>(this);
        }

        private void btnVanbang_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmVanbang>(this);
        }

        private void btnNgonngu_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmNgonngu>(this);
        }

        private void btnTinhthanh_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmTinh>(this);
        }

        private void btnQuanhe_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmQuanhe>(this);
        }

        private void btnTieuchuan_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<Catalog.FrmTieuchuan>(this);
        }
        #endregion

        private void btnUngvien_ItemClick(object sender, ItemClickEventArgs e)
        {
            Extend.ShowRight<FrmUngvien>(this);
        }
    }
}